﻿@typeparam TValue
@inherits Blazorise.Check<TValue>
<label class="@WrapperClassNames">
    <span class="@CheckboxClassNames">
        <input @ref="@ElementRef" id="@ElementId" type="checkbox" class="@ClassNames" style="@StyleNames" disabled="@Disabled" readonly="@ReadOnly" checked="@CurrentValue" tabindex="@TabIndex" @onchange="@OnChangeHandler" @onkeydown="@OnKeyDownHandler" @onkeypress="@OnKeyPressHandler" @onkeyup="@OnKeyUpHandler" @onblur="@OnBlurHandler" @onfocus="@OnFocusHandler" @onfocusin="@OnFocusInHandler" @onfocusout="@OnFocusOutHandler" @attributes="@Attributes" />
        <span class="@InnerClassNames"></span>
    </span>
    <span>
        @ChildContent
        @Feedback
    </span>
</label>
@code{
    string WrapperClassNames
    {
        get
        {
            var sb = new System.Text.StringBuilder( "ant-checkbox-wrapper" );

            if ( Checked?.ToString() == bool.TrueString )
            {
                sb.Append( " ant-checkbox-wrapper-pointer" );
            }

            return sb.ToString();
        }
    }

    string CheckboxClassNames
    {
        get
        {
            var sb = new System.Text.StringBuilder( "ant-checkbox" );

            if ( Checked?.ToString() == bool.TrueString )
            {
                sb.Append( " ant-checkbox-checked" );
            }

            if ( Indeterminate == true )
            {
                sb.Append( " ant-checkbox-indeterminate" );
            }

            return sb.ToString();
        }
    }

    string InnerClassNames
        => "ant-checkbox-inner";
}
